import request from '@/utils/request'
import setting from '@/setting.js'
import axios from 'axios'
import { BASE_API } from '@/api/baseUrl'
const TIMEOUT = setting.requestTimeout
const service = axios.create({
  baseURL: BASE_API(),
  // baseURL: 'http://192.168.1.141:5100/ibps/',
  withCredentials: true,
  timeout: TIMEOUT,
});
service.interceptors.request.use(function (config) {
  return config;
}, function (error) {
  // Do something with response error
  return Promise.reject(error);
})
export function queryBigMonitorScreenJksbxx(params) {
  return service({
    url: "/smartSite/v3/bigScreenDataQueryService/queryBigMonitorScreenJksbxx",
    method: "post",
    params,
  });
};
export function queryBigMonitorScreenProject(params) {
  return service({
    url: "/smartSite/v3/bigScreenDataQueryService/queryBigMonitorScreenProject",
    method: "post",
    params,
  });
};
export function findThreeOrg() {
  return service({
    url: "/smartSite/v3/org/findThreeOrg",
    method: "post",
  });
};
// 监控大屏-进出场与考勤
export function queryBigMonitorScreen2checkOn(params) {
  return service({
    url: "/smartSite/v3/bigScreenDataQueryService/queryBigMonitorScreen2checkOn",
    method: "get",
    params
  });
};
// 监控大屏-人员统计
export function queryBigMonitorScreen2Person(params) {
  return service({
    url: "/smartSite/v3/bigScreenDataQueryService/queryBigMonitorScreen2Person",
    method: "get",
    params
  });
};
// 监控大屏-项目统计
export function queryBigMonitorScreen2Project(params) {
  return service({
    url: "/smartSite/v3/bigScreenDataQueryService/queryBigMonitorScreen2Project",
    method: "get",
    params
  });
};
export function videoSurveillance(params) {
  return request({
    url: "/smartSite/v3/videoSurveillance/videoSurveillanceQuery",
    method: "post", params
  });
};
export const debounceFn = (func, wait) => {
  let timeout = '';
  return (v) => {
    if (timeout) {
      clearTimeout(timeout);
    }
    timeout = setTimeout(() => {
      func(v);
    }, wait);
  }
};
export function fontChart(res) {
  let clientWidth = document.querySelector('.content-wrap').clientWidth;
  if (!clientWidth) return;
  let fontSize = 3.2 * (clientWidth / (1920))
  return res * fontSize;
}
export function getpercentage(small, big, fix = 2,isbfb=true) {
  let bfb =  isNaN(small / big)?0:small / big
  let str= (bfb * 10000 / 100.0).toFixed(fix) + (isbfb?"%":'');
  return str
}